Skip to content

Replace custom markdown parsing with marked, KaTeX, and some custom plugins for matrix things#727

Open
7w1 wants to merge 28 commits intodevfrom
feat/marked-markdown
Open

Replace custom markdown parsing with marked, KaTeX, and some custom plugins for matrix things#727
7w1 wants to merge 28 commits intodevfrom
feat/marked-markdown

Conversation

@7w1
Copy link
Copy Markdown
Member

@7w1 7w1 commented Apr 30, 2026

Description

Replaced Cinny's custom markdown parsing with marked which should drastically reduce the various random obscure errors and crashes caused by it.
Added math rendering support with KaTeX, sent using standard formatting of $ for inline and $$ for block with LaTeX.

Supersedes #726
Fixes #711
Fixes #587
Fixes #467
Fixes #684

Tbh I doubt I've tested this enough so there's probably still a bunch of bugs, especially in parsing html back to markdown, but hopefully it's less than our current system?

Might consider using another library like Turndown for converting html into markdown, currently using a partial custom parser with... well okay results.

Updated to also remove the WYSIWYG editor because it's largely unused, can be entirely covered by markdown, and complicates translating html to markdown. Keyboard shortcuts from the editor have been rewritten to instead apply markdown syntax.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change - removes the WYSIWYG editor.
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

AI disclosure:

  • Partially AI assisted (clarify which code was AI assisted and briefly explain what it does).
  • Fully AI generated (explain what all the generated code does in moderate detail).

Tests were AI generated and then reviewed by me. I can confirm that the tests probably test the right stuff.
I had AI do the initial merge and write the marked plugins for the link preview hiding and spoiler hiding features, which I then tested and reviewed.

@7w1 7w1 requested a review from hazre as a code owner April 30, 2026 06:38
Comment thread src/app/components/message/MsgTypeRenderers.tsx Dismissed
@hazre
Copy link
Copy Markdown
Member

hazre commented Apr 30, 2026

I haven't looked at the code but where possible, please load libraries and such dynamically! So it's loaded when needed to reduce initial load and situations where people don't use a specific feature like math rendering.

@nushea
Copy link
Copy Markdown
Contributor

nushea commented Apr 30, 2026

the rendering side of the issue peprsists within this pr, could you introduce the message rendering part of this pr #726 (or actually the equivalent pr from cinny directly bcs it has more root changes that would hopefully be better since ajbura proposed the css solution even if it looks very overreaching 🤷🏻‍♀️) because this would would still be a persistent issue with people that use cinny and happen to for whatever reason send a message that ends in an empty list 🤷🏻‍♀️

@7w1
Copy link
Copy Markdown
Member Author

7w1 commented Apr 30, 2026

Okay firefox is actually fixed now and KaTeX is loaded dynamically!

@github-actions
Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

Status Preview URL Commit Alias Updated (UTC)
✅ Deployment successful! https://pr-727-sable.raspy-dream-bb1d.workers.dev 5991790 pr-727 Thu, 30 Apr 2026 19:59:33 GMT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants